package development.hdk.mindmapfornandroid;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import development.hdk.tree.Tree;

public class TreeAdapter extends ArrayAdapter<Tree>
{
  private Context context;
  private ImageView treeIcon;
  private TextView treeName;
  private List<Tree> trees = new ArrayList();

  public TreeAdapter(Context paramContext, int paramInt, List<Tree> paramList)
  {
    super(paramContext, paramInt, paramList);
    this.context = paramContext;
    this.trees = paramList;
  }

  public static int calculateInSampleSize(BitmapFactory.Options paramOptions, int paramInt1, int paramInt2)
  {
    int i = paramOptions.outHeight;
    int j = paramOptions.outWidth;
    int k = 1;
    /*if ((i > paramInt2) || (j > paramInt1))
      if (j <= i)
        break label44;
    lable 144: for (k = Math.round(i / paramInt2); ; k = Math.round(j / paramInt1))*/
      return k;
  }

  public static Bitmap decodeSampledBitmapFromResource(Resources paramResources, int paramInt1, int paramInt2, int paramInt3)
  {
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(paramResources, paramInt1, localOptions);
    localOptions.inSampleSize = calculateInSampleSize(localOptions, paramInt2, paramInt3);
    localOptions.inJustDecodeBounds = false;
    return BitmapFactory.decodeResource(paramResources, paramInt1, localOptions);
  }

  public int getCount()
  {
    return this.trees.size();
  }

  public Tree getItem(int paramInt)
  {
    return (Tree)this.trees.get(paramInt);
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView = paramView;
    if (localView == null)
      localView = ((LayoutInflater)getContext().getSystemService("layout_inflater")).inflate(2130903047, paramViewGroup, false);
    Tree localTree = getItem(paramInt);
    this.treeIcon = ((ImageView)localView.findViewById(2131165208));
    this.treeName = ((TextView)localView.findViewById(2131165209));
    this.treeName.setText(localTree.getTreeName());
    int i = this.context.getResources().getIdentifier(localTree.getIcon(), "drawable", this.context.getPackageName());
    this.treeIcon.setImageBitmap(decodeSampledBitmapFromResource(this.context.getResources(), i, (int)TypedValue.applyDimension(1, 48.0F, this.context.getResources().getDisplayMetrics()), (int)TypedValue.applyDimension(1, 48.0F, this.context.getResources().getDisplayMetrics())));
    return localView;
  }
}

/* Location:           D:\APKtoJava_RC2\tools\classes-dex2jar.jar
 * Qualified Name:     com.qdvsoftworks.schematicmind.TreeAdapter
 * JD-Core Version:    0.6.0
 */